{% extends('layout.html') %}
{% block body %}
<!-- slider (good UX however kind of pointless if you don't have anything to display that's really neat? -->
{% if hasSlider %}
{% include('slider.html') %}
{% endif %}
<!-- Tabs for statistics -->
<section id="dropdown" class="section">
    <div class="container">
        <div class="col s12 m12">
            <div class="card-panel">
                <h4 class="red-text">Detection Logs</h4>
                <div class="row">
                    <form action="system/reports" method="POST">
                        <div class="input-field col s10 m4">
                            <select name="table" onchange="this.form.submit()">
                                <option value="db_time" {% if menu=='1' %} selected {% endif %}
                                    >Domains Blocked (by time)</option>
                                <option value="db_count" {% if menu=='2' %} selected {% endif %}
                                    >Domains Blocked (by count)</option>
                                <option value="dv_time" {% if menu=='3' %} selected {% endif %}
                                    >Domains Viewed (by time)</option>
                                <option value="dv_count" {% if menu=='4' %} selected {% endif %}
                                    >Domains Viewed (by count)</option>
                                <option value="ad_time" {% if menu=='5' %} selected {% endif %}
                                    >All Domains (by time)</option>
                                <option value="ad_count" {% if menu=='6' %} selected {% endif %}
                                    >All Domains (by count)</option>
                                <option value="ip_hosts_time" {% if menu=='7' %} selected {% endif %}
                                    >IP Hosts (by time)</option>
                                <option value="ips_time" {% if menu=='8' %} selected {% endif %}
                                    >IPS (by time)</option>
                                <option value="ic_all" {% if menu=='9' %} selected {% endif %}
                                    >Infected Clients</option>
                            </select>
                            <label for="table">Reports</label>
                        </div>
                        <noscript>
                        <div class="input-field col s3 m3">
                            <button class="btn waves-effect waves-light col s4">
                                <i class="material-icons">cached</i>
                            </button>
                        </div>
                        </noscript>
                    </form>
                </div>
                <div class="row">
                    <table class="striped">
                        <!-- DNS Proxy Table -->
                        {% if table=='1' %}
                        <thead>
                        <tr>
                            <th>Source</th>
                            <th>Domain</th>
                            <th>Category</th>
                            <th>Reason</th>
                            <th>Action</th>
                            <th>Count</th>
                            <th>Last Seen</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if table_data %}
                        {% for entry in table_data %}
                        <tr>
                            <td>{{entry[0]}}</td>
                            <td>{{entry[1]}}</td>
                            <td>{{entry[2]}}</td>
                            <td>{{entry[3]}}</td>
                            <td>{{entry[4]}}</td>
                            <td>{{entry[5]}}</td>
                            <td>{{entry[6]}}</td>
                        </tr>
                        </tbody>
                        {% endfor %}
                        {% else %}
                        <tr>
                            <td>No Logs</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </tbody>
                        {% endif %}
                        </tbody>
                        <!-- IP HOSTS TABLE-->
                        {% elif table=='2' %}
                        <thead>
                        <tr>
                            <th>Local IP</th>
                            <th>Remote IP</th>
                            <th>Category</th>
                            <th>Direction</th>
                            <th>Action</th>
                            <th>Timestamp</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if table_data %}
                        {% for entry in table_data %}
                        <tr>
                            <td>{{entry[0]}}</td>
                            <td>{{entry[1]}}</td>
                            <td>{{entry[2]}}</td>
                            <td>{{entry[3]}}</td>
                            <td>{{entry[4]}}</td>
                            <td>{{entry[5]}}</td>
                        </tr>
                        </tbody>
                        {% endfor %}
                        {% else %}
                        <tr>
                            <td>No Logs</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </tbody>
                        {% endif %}
                        <!-- IPS TABLE -->
                        {% elif table=='3' %}
                        <thead>
                        <tr>
                            <th>Source</th>
                            <th>Protocol</th>
                            <th>Attack Type</th>
                            <th>Action</th>
                            <th>Last Seen</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if table_data %}
                        {% for entry in table_data %}
                        <tr>
                            <td>{{entry[0]}}</td>
                            <td>{{entry[1]}}</td>
                            <td>{{entry[2]}}</td>
                            <td>{{entry[3]}}</td>
                            <td>{{entry[4]}}</td>
                        </tr>
                        </tbody>
                        {% endfor %}
                        {% else %}
                        <tr>
                            <td>No Logs</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </tbody>
                        {% endif %}
                        {% elif table=='4' %}
                        <thead>
                        <tr>
                            <th></th>
                            <th>Local MAC</th>
                            <th>Local IP</th>
                            <th>Detected Host</th>
                            <th>Reason</th>
                            <th>User</th>
                            <th>Last Seen</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if table_data %}
                        {% for entry in table_data %}
                        <tr>
                            <td>
                                <a class="waves-effect waves-light btn modal-trigger" href="#rep-modal1-{{loop.index}}"><i class="material-icons">remove</i></a>
                                <div id="rep-modal1-{{loop.index}}" class="modal">
                                    <div class="modal-content">
                                        <h5 class="red-text">Are you sure you want to remove the infected client from the list? Is it now clean?</h5>
                                    </div>
                                    <form action="/system/reports" method="POST">
                                        <input type="hidden" name="i_client_remove">
                                        <input type="hidden" name="table" value="ic_all">
                                        <div class="modal-footer">
                                            <button class="btn waves-effect waves-light">YES</button>
                                            <a class="modal-close waves-effect waves-green btn-flat">Cancel</a>
                                            <input type="hidden" name="infected_client" value="{{entry[0]}}">
                                            <input type="hidden" name="detected_host" value="{{entry[2]}}">
                                        </div>
                                    </form>
                                </div>
                            </td>
                            <td>{{entry[0]}}</td>
                            <td>{{entry[1]}}</td>
                            <td>{{entry[2]}}</td>
                            <td>{{entry[3]}}</td>
                            <td>{{entry[4]}}</td>
                            <td>{{entry[5]}}</td>
                        </tr>
                        </tbody>
                        {% endfor %}
                        {% else %}
                        <tr>
                            <td></td>
                            <td>No Logs</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </tbody>
                        {% endif %}
                        {% endif %}
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}
